In 1753 align create statuses across workflows#245
Conversation
Why these changes are being introduced: * Statuses for item submission post batch creation now comprise of "create_success|failed|skipped", not just "batch_created". This change is to support workflows that require writing item submissions to the DynamoDB table even if an error occurs during batch creation. How this addresses that need: * Remove references to ItemSubmissionStatus.BATCH_CREATED Side effects of this change: * None Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/IN-1753
Coverage Report for CI Build 27027257687Warning No base build found for commit Coverage: 83.438%Details
Uncovered Changes
Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
Aligns “create” step item-submission statuses across workflows by replacing the legacy batch_created status with explicit create_success|create_failed|create_skipped, and restores create-step reporting of batch-creation errors via an errors.csv attachment.
Changes:
- Remove
BATCH_CREATEDand update create-step status expectations toCREATE_SUCCESSacross workflows/tests. - Stop the base workflow from overwriting statuses during
_create_batch_in_db, requiring workflows to set create statuses duringprepare_batch(). - Reintroduce create-step error reporting by allowing create reports to attach an
errors.csvwhen batch creation fails.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
dsc/db/models.py |
Removes BATCH_CREATED enum value to enforce the new create-status scheme. |
dsc/workflows/base/workflow.py |
Stops default status assignment in _create_batch_in_db; extends send_report() to pass optional report kwargs. |
dsc/workflows/simple_csv/workflow.py |
Sets CREATE_SUCCESS during prepare_batch() for SimpleCSV-derived workflows. |
dsc/workflows/opencourseware/workflow.py |
Sets CREATE_SUCCESS during prepare_batch() for OpenCourseWare workflow. |
dsc/reports/base.py |
Adds optional errors.csv attachment for create reports; skips attachments whose generators return None. |
dsc/cli.py |
Passes batch-creation errors into the create report when batch creation fails. |
tests/conftest.py |
Renames DynamoDB fixture and updates seeded records/statuses to CREATE_SUCCESS. |
tests/test_cli.py |
Updates fixture name and replaces BATCH_CREATED expectations with CREATE_SUCCESS. |
tests/test_db.py |
Updates fixture name for DynamoDB-backed tests. |
tests/test_item_submission.py |
Updates fixture name and replaces BATCH_CREATED expectations with CREATE_SUCCESS. |
tests/test_workflow_base.py |
Updates fixture name and replaces BATCH_CREATED expectations with CREATE_SUCCESS. |
tests/test_workflow_archivesspace.py |
Updates fixture name for DynamoDB-backed workflow tests. |
tests/test_workflow_opencourseware.py |
Updates fixture name and adds CREATE_SUCCESS to expected prepared submissions. |
tests/test_workflow_simple_csv.py |
Adds CREATE_SUCCESS to expected prepared submissions. |
Comments suppressed due to low confidence (1)
dsc/reports/base.py:47
Report.__init__/Report.loadannotate**kwargsaslist, which implies every kwarg value must be alist. In practiceerrorsmay beNone, and future report kwargs may not be lists. Loosen the kwarg value type to avoid misleading type hints (and potential static-analysis noise).
def __init__(self, workflow_name: str, batch_id: str, **kwargs: list):
self.workflow_name = workflow_name
self.batch_id = batch_id
self.report_date = datetime.now(tz=UTC).strftime("%Y%m%dT%H%M%SZ")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Why these changes are being introduced: * The digitized theses workflow allows for writing records to DynamoDB in cases whereas other workflows (OpenCourseWare and SCCS) would normally raise a BatchCreationFailedError. When a workflow skips writing to DynamoDB because of a batch creation error, the 'create' reporting module needs a way to access errors. NOTE: This returns the creation of an errors CSV file with the new reporting structure. How this addresses that need: * Workflow.send_report accepts kwargs, allowing assignment of errors during `create` step * Add 'errors' attribute to base `Report` class * Allow attachment method to return None Side effects of this change: * None Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/IN-1753
cb8cbae to
e91a29f
Compare
Purpose and background context
Statuses for item submission post batch creation now comprise of "create_success|failed|skipped", not just "batch_created". This change is to support workflows that require writing item submissions to the DynamoDB table even if an error occurs during batch creation. As a reminder, the
opencoursewareandsccsworkflows will only write item submissions to DynamoDB when no errors occur during the batch creation step, whereas thedigitized-thesesworkflow allows item submissions with statusCREATE_FAILED|CREATE_SKIPPED.The following updates were applied:
statusassignment ofCREATE_SUCCESSfrom baseWorkflow.create_batch()methodOpenCourseWareandSCCSworkflow to set statuses duringprepare_batch()methodNOTE: The second commit in this PR resolves an issue introduced by the reporting module updates, which unintentionally removed the creation of an errors CSV file, which is still required for the
opencoursewareandsccsworkflows, which do not write records to DynamoDB in the event of a batch creation error. The proposed solution in the second commit is intended to be minimal, and it's worth continuing to reflect on this difference when considering future enhancements to reporting.How can a reviewer manually see the effects of these changes?
For now, a review of code changes is sufficient.
Includes new or updated dependencies?
NO
Changes expectations for external applications?
NO
What are the relevant tickets?
Code review